home *** CD-ROM | disk | FTP | other *** search
/ Network Supervisor's Toolkit / Network Supervisor's Toolkit.iso / tools / nwtp06 / swapname.pas < prev    next >
Pascal/Delphi Source File  |  1996-07-10  |  3KB  |  97 lines

  1. {$X+,B-,V-} {essential compiler directives}
  2.  
  3. program swapnames; { as of 950301 }
  4.  
  5. { Example for the nwBindry unit / NwTP 0.6 API. (c) 1993,1995, R.Spronk }
  6.  
  7. { AREA:NOVELL
  8. (1394)  Thu 30 Sep 93 16:07
  9. By: JAMES SIMONSON
  10. To: All
  11. Re: Novell 3.11/4.01 bindery access
  12. ------------------------------------------------------------
  13.  
  14. Is there a way to access the full name information inthe bindery files?
  15. Here's the scoop:
  16.  
  17. We've got "firstname mi lastname" in the FULLNAME space in the user record.
  18. We need to convert that to "lastname, firstname mi" & place that
  19. information BACK into the FULLNAME field. Is there any relatively fast way
  20. to do this conversion?
  21.  
  22. --- SLMAIL v3.0  (#0623)
  23.  * Origin: WorkStations Unlimited / 312-404-2824 (1:115/404) }
  24.  
  25. { This program will reverse all first & last names in the bindery.
  26.   Lastname is defined as being everything after the last space in the full name.
  27.   This may not be true for all names.
  28.   If there is no space in the full name, nothing changes. }
  29.  
  30. uses nwBindry;
  31.  
  32. Var lastObjSeen:LongInt;
  33.     objName    :string;
  34.     objType    :word;
  35.     objId      :LongInt;
  36.     objFlag,objSec:Byte;
  37.     hasProp    :boolean;
  38.  
  39.     propVal  :Tproperty;
  40.     moreseg  :boolean;
  41.     propFlags:Byte;
  42.  
  43.     NewName,FullName:string;
  44.     t:byte;
  45.     s:string;
  46. begin
  47. IF NOT IsShellLoaded
  48.  then begin
  49.       writeln('Load network shell before executing this testprogram.');
  50.       halt(1);
  51.       end;
  52.  
  53. writeln('SWAPNAME: Will swap the first and last names of the IDENTIFICATION');
  54. writeln('          property in the bindery. (Full Name of an object)');
  55. writeln;
  56. writeln('--WARNING: Changes the property values irrevokably ! --');
  57. writeln;
  58. writeln('Type ''y'' and <Return> to continue.. (all else will abort)');
  59. readln(s);
  60. if (s[0]=#0) or ((s[1]<>'y') and (s[1]<>'Y'))
  61.  then halt(1);
  62.  
  63. LastObjSeen:=-1;
  64. WHILE ScanBinderyObject('*',1,LastObjSeen,
  65.                   objName,objType,objId,objFlag,objSec,hasProp)
  66.  do begin
  67.     IF ReadPropertyValue(objName,objType,'IDENTIFICATION',1,
  68.                          propVal,moreSeg,propFlags)
  69.     then begin
  70.          t:=1;
  71.          while (propVal[t]<>0)
  72.           do begin FullName[t]:=chr(propVal[t]);inc(t) end;
  73.          FullName[0]:=chr(t-1);
  74.          IF pos(',',FullName)=0
  75.           then begin
  76.                writeln(FullName);
  77.                while fullName[ord(fullName[0])]=' '
  78.                 do dec(FullName[0]);
  79.                t:=ord(FullName[0]);
  80.                while (t>0) and (FullName[t]<>' ') do dec(t);
  81.                if t>0
  82.                 then begin
  83.                      NewName:=copy(FullName,t+1,255)+', '
  84.                                    +copy(FullName,1,t-1);
  85.                      writeln(newname);
  86.                      fillChar(propVal,SizeOf(propVal),#0);
  87.                      for t:=1 to ord(newName[0])
  88.                       do propVal[t]:=ord(newName[t]);
  89.                      WritePropertyValue(objName,objType,
  90.                          'IDENTIFICATION',1,propVal,FALSE);
  91.                      end;
  92.                end;
  93.          end;
  94.     end;
  95.  if nwBindry.result<>$FC then writeln('error scanning bindery');
  96. end.
  97.